/**
 * Created with CLion.
 * Description: 
 * User: loong
 * Date: 2025/5/19
 * Time: 22:36
 */

#ifndef SPRITEANIM_H
#define SPRITEANIM_H
#include "Sprite.h"

class SpriteAnim : public Sprite
{
public:
    static SpriteAnim * AddSpriteAnimChild(ObjectScreen * parent, const std::string & _file_path, float _scale = 1.0f, Anchor _anchor = Anchor::CENTER);

    void Update(float _dt) override;

    void SetTexture(const Texture & texture) override;

    int  CurrentFrame() const { return current_frame_; }
    void SetCurrentFrame(int _current) { current_frame_ = _current; }

    float FrameTimer() const { return frame_timer_; }
    void  SetFrameTimer(float _timer) { frame_timer_ = _timer; }

    bool IsLoop() const { return is_loop_; }
    void SetLoop(bool _is_loop) { is_loop_ = _is_loop; }

private:
    int   current_frame_ {0};
    int   total_frames_ {0};
    int   fps_ {10};
    float frame_timer_ {0.0f};
    bool  is_loop_ {true};
};

#endif//SPRITEANIM_H
